using System;
using NUnit.Framework;
using DotNetXmlSwfChart;

namespace DotNetXmlSwfChart.UnitTest
{
    [TestFixture]
    public class LegendLabelFixture
    {
        [Test]
        public void LayoutHorizontalBulletSquare()
        {
            LegendLabelTest(LegendLabelLayout.horizontal, LegendLabelBullet.square);
        }

        [Test]
        public void LayoutVerticalBulletSquare()
        {
            LegendLabelTest(LegendLabelLayout.vertical, LegendLabelBullet.square);
        }

        [Test]
        public void LayoutHorizontalBulletCircle()
        {
            LegendLabelTest(LegendLabelLayout.horizontal, LegendLabelBullet.circle);
        }

        [Test]
        public void LayoutVerticalBulletCircle()
        {
            LegendLabelTest(LegendLabelLayout.vertical, LegendLabelBullet.circle);
        }

        [Test]
        public void LayoutHorizontalBulletLine()
        {
            LegendLabelTest(LegendLabelLayout.horizontal, LegendLabelBullet.line);
        }

        [Test]
        public void LayoutVerticalBulletLine()
        {
            LegendLabelTest(LegendLabelLayout.vertical, LegendLabelBullet.line);
        }

        private void LegendLabelTest(LegendLabelLayout layout, LegendLabelBullet bullet)
        {
            string testXml =
                "<legend_label layout='{0}' " +
                              "bullet='{1}' " +
                              "font='Arial' " +
                              "bold='True' " +
                              "size='10' " +
                              "color='ffffff' " +
                              "alpha='2' " +
                              "/>";
            LegendLabel ll = new LegendLabel();
            ll.Layout = layout;
            ll.Bullet = bullet;
            ll.Font = "Arial";
            ll.Bold = true;
            ll.Size = 10;
            ll.Color = "ffffff";
            ll.Alpha = 2;
            Assert.AreEqual(
                string.Format(testXml, layout.ToString(), bullet.ToString()),
                ll.ToSourceXML());
        }
    }
}
